import 'package:flutter/material.dart';
import 'package:osc/common/MyTextStyle.dart';
import 'package:osc/models/entity/osc_user.dart';
import 'package:osc/res/dimens.dart';
import 'package:osc/ui/pages/user/user_profile.dart';
import 'package:osc/utils/navigator_util.dart';

import 'osc_portraint_widget.dart';

class OscUserWidget extends StatelessWidget {
  final OscUser user;
  const OscUserWidget({Key key, @required this.user}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: (){
        NavigatorUtil.pushPage(context, UserProfile(userId: user.id));
      },
      child: Container(
        color: Colors.white,
        padding: EdgeInsets.all(Dimens.gap_activity_horizontal),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Padding(
              padding: EdgeInsets.only(right: Dimens.gap_view_normal),
              child: OscPortraitWidget(id: user.id, portraitImageUrl: user.portrait,),
            ),
            Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text(user.name, style: MyTextStyle.USER_LIST_TITLE,),
                    buildDescription(user.more.expertise),
                  ],
                )
            ),
          ],
        ),
      ),
    );
  }

  buildDescription(String msg){
    return Padding(
      padding: EdgeInsets.symmetric(vertical: Dimens.gap_view_smaller),
      child: Text(msg, style: MyTextStyle.LIST_BODY,),
    );
  }
}
